<!DOCTYPE html>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script> -->
    <script src="../node_modules/vue/dist/vue.global.js"></script>
</head>

<body>
    <div id="app">

    </div>
</body>

</html>
<script>
    //
    const { createApp } = Vue;
    const vm = createApp({
        data() {
            return {
                count: 0
            }
        },
        created() {
            //01: 进行数据请求(默认get)
            // fetch('https://api.i-lynn.cn/college?page=2').then(res => {
            //     console.log('res', res);
            //     return res.json()
            // }).then(data => {
            //     console.log(data);
            // })
            //02:post 请求 jsoN 格式提交参数
            fetch('https://api.i-lynn.cn/college', {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json'
                    // 'Content-Type': 'application/x-www-form-urlencoded',
                },
                body: JSON.stringify({ username: '小翠', age: 18 }) // 设置参数
            }).then(res => res.json()).then(res => {
                console.log('post', res);
            })

            //03:post 请求 表单编码格式提交参数
            // fetch('https://api.i-lynn.cn/college', {
            //     method: 'POST',
            //     headers: {
            //         // 'Content-Type': 'application/json'
            //         'Content-Type': 'application/x-www-form-urlencoded',
            //     },
            //     body: 'username=小丽&age=15' // 设置参数
            // }).then(res => res.json()).then(res => {
            //     console.log('post', res);
            // })
        }

    }).mount('#app')
</script>